'''
Created on Jul 22, 2009

@author: xin
@author: Mikael Rousson
'''
import numpy
import pylab

def pyr_band_indice(pind, band):
    """ Returns indices for accessing a subband from a pyramid (gaussian, 
    laplacian, QMF/wavelet, steerable).
    """

    if band > pind.shape[0] or band < 1:
        print "BAND_NUM must be between 1 and number of pyramid bands %s" \
        % (pind.shape[0])
    if (pind.shape[1] != 2):
        print "INDICES must be an N*2 matrix \
        indicating the size of the pyramid subbands"
    ind = 0
    for l in range(band - 1):
        ind = ind + numpy.prod(pind[l, :], 0)
    indices = range(ind + numpy.prod(pind[band - 1, :], 0))[ind:ind + numpy.prod(pind[band - 1, :], 0)]
    return indices
